package com.bjsxt.livegoods.entity;

import java.io.Serializable;
import java.util.Objects;

/**
 * 轮播图实体 存储在MongoDB中
 * 图片存储在FastDFS中的。需要存储组名和文件名。
 */
public class Banner implements Serializable {
    private String id;
    private String img;//轮播图的图片地址
    private String groupId;//FastDFS的分组名称
    private String fileId;//FastDFS的文件名称
    private String serverURI;//FastDFS Storage所在地址。 ip:8888
    private String fileName;//图片的原始名称

    public Banner() {
    }

    public Banner(String id, String img, String groupId, String fileId, String serverURI, String fileName) {
        this.id = id;
        this.img = img;
        this.groupId = groupId;
        this.fileId = fileId;
        this.serverURI = serverURI;
        this.fileName = fileName;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getImg() {
        return  "http://"+serverURI+"/"+groupId+"/"+fileId;//ip:port group1 + M00/00/00/xxx.jpg
    }


    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getFileId() {
        return fileId;
    }

    public void setFileId(String fileId) {
        this.fileId = fileId;
    }

    public String getServerURI() {
        return serverURI;
    }

    public void setServerURI(String serverURI) {
        this.serverURI = serverURI;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Banner banner = (Banner) o;
        return Objects.equals(id, banner.id) && Objects.equals(groupId, banner.groupId) && Objects.equals(fileId, banner.fileId) && Objects.equals(serverURI, banner.serverURI) && Objects.equals(fileName, banner.fileName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id,groupId, fileId, serverURI, fileName);
    }

    @Override
    public String toString() {
        return "Banner{" +
                "id='" + id + '\'' +
                ", img='" + img + '\'' +
                ", groupId='" + groupId + '\'' +
                ", fileId='" + fileId + '\'' +
                ", serverURI='" + serverURI + '\'' +
                ", fileName='" + fileName + '\'' +
                '}';
    }
}
